<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BasesfTinyMceAssetsActionsclass
 *
 * @author leonardo
 */
class BasesfContactFormActions extends sfActions
{

  public function executeIndex(sfWebRequest $request)
  {
    $this->form = new sfContactForm();    
  }

  public function executeSend(sfWebRequest $request)
  {
    $this->form = new sfContactForm();   
    
    if ($request->isMethod('post'))
    {
      $this->form->bind($request->getParameter('contact'));
      $this->getUser()->setAttribute('captcha', NULL);
      
      if ($this->form->isValid())
      {
        
        $message = Swift_Message::newInstance()
          ->setFrom($this->form->getValue('email'))
          ->setTo(sfConfig::get('app_sf_contact_form_email'))
		  ->setSubject($this->form->getValue('subject'))          
          ->setBody($this->getPartial('html'), 'text/html')
          ->addPart($this->getPartial('text'));

        $this->getMailer()->send($message);
        $this->getUser()->setFlash('notice', 'message sent');
      }
    }
    $this->setTemplate('index');
  }

}
?>
